<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace AdaPaySdk;

class Payment extends \AdaPay\AdaPay
{
    public $endpoint = "/v1/payments";
    private static $instance;
    public function __construct()
    {
        parent::__construct();
        $this->sdk_tools = SDKTools::getInstance();
    }
    public function create($params = [])
    {
        $params["currency"] = "cny";
        $params["sign_type"] = "RSA2";
        $request_params = $params;
        $request_params = $this->do_empty_data($request_params);
        $req_url = $this->gateWayUrl . $this->endpoint;
        $header = $this->get_request_header($req_url, $request_params, self::$header);
        $this->result = $this->ada_request->curl_request($req_url, $request_params, $header, $is_json = true);
    }
    public function queryList($params = [])
    {
        ksort($params);
        $request_params = $this->do_empty_data($params);
        $req_url = $this->gateWayUrl . $this->endpoint . "/list";
        $header = $this->get_request_header($req_url, http_build_query($request_params), self::$headerText);
        $this->result = $this->ada_request->curl_request($req_url . "?" . http_build_query($request_params), "", $header, false);
    }
    public function query($params = [])
    {
        ksort($params);
        $id = isset($params["payment_id"]) ? $params["payment_id"] : "";
        $request_params = $params;
        $req_url = $this->gateWayUrl . $this->endpoint . "/" . $id;
        $header = $this->get_request_header($req_url, http_build_query($request_params), self::$headerText);
        $this->result = $this->ada_request->curl_request($req_url . "?" . http_build_query($request_params), "", $header, false);
    }
    public function close($params = [])
    {
        $id = isset($params["payment_id"]) ? $params["payment_id"] : "";
        $request_params = $params;
        $request_params = $this->do_empty_data($request_params);
        $req_url = $this->gateWayUrl . $this->endpoint . "/" . $id . "/close";
        $header = $this->get_request_header($req_url, $request_params, self::$header);
        $this->result = $this->ada_request->curl_request($req_url, $request_params, $header, $is_json = true);
    }
}

?>